package java10;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

//使用新的工具类
public class DruidTest02 {
    public static void main(String[] args){
        //完成添加操作：给account表添加一条记录
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            //获取连接
            conn = JDBCutil.getConnection();
            //定义sql
            String sql = "insert into account values(?,?,?)";
            //获取pstmt对象
            pstmt = conn.prepareStatement(sql);
            //给?赋值
            pstmt.setInt(1,3);
            pstmt.setString(2,"wangwu");
            pstmt.setDouble(3,2500);
            int count = pstmt.executeUpdate();
            System.out.println(count);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCutil.close(pstmt,conn);
        }
    }
}
